function index = closest_az_el(az_v,el_v,az,el)
	[x_v,y_v,z_v] = azel2xyz(az_v,el_v);
	[x,y,z] = azel2xyz(az,el);
	d2 = abs(x_v-x).^2+abs(y_v-y).^2+abs(z_v-z).^2;
	[tmp,index] = min(d2);
return;

function [x,y,z] = azel2xyz(az,el)
	y = sin(el*pi/180);
	x = cos(el*pi/180).*sin(az*pi/180);
	z = cos(el*pi/180).*cos(az*pi/180);
return;
